﻿namespace MyCoreLib.Automation.Data.SqlClient.CSharp
{
    using System;
    using System.Linq;

    using MyCoreLib.Automation.Data.SqlClient.Model;

    public partial class RRTStoredProcedureResultSet
    {
        private readonly string Name;
        private readonly string EntityClassName;
        private readonly string EnumeratorClassName;
        private readonly string Schema;
        private readonly string FullName;

        private readonly string InterfacesCsv;

        public RRTStoredProcedureResultSet(StoredProcedureInfo info, ISqlClientCSharpCodeFormatter csharpCodeFormatter)
            : base(csharpCodeFormatter)
        {
            if (ReferenceEquals(info, null))
            {
                throw new ArgumentNullException("info");
            }

            Name = info.Name;
            Schema = info.Schema;
            FullName = info.FullName;

            EntityClassName = csharpCodeFormatter.GetEntityClassName(info);
            EnumeratorClassName = csharpCodeFormatter.GetEnumeratorClassName(info);
            var interfaceNames = from c in info.Contracts select csharpCodeFormatter.GetInterfaceName(c.Name);
            InterfacesCsv = String.Join(", ", interfaceNames);

        }
    }
}
